package com.ge.myoned.rabbitmq;

import cn.hutool.core.date.DateUtil;
import com.ge.myoned.config.RabbitMQConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Author geqingxiang
 * @PackageName myProject
 * @Package com.ge.oned.rabbitmq
 * @Date 2023/6/7 17:53
 * @Version 1.0
 */
@Component
@Slf4j
public class MessageReceiver {

    @RabbitHandler
    @RabbitListener(queues = RabbitMQConfig.DLK_QUEUE)
    public void onMessage(Message message){
        log.info("使用死信队列，{}收到消息:{}", DateUtil.now(),new String(message.getBody()));
    }
}
